package com.gdziarmaga.webshop.review.model;

import java.util.Date;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.gdziarmaga.webshop.core.dao.GenericDaoImpl;

@Repository("reviewRepo")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class ReviewDAOImpl extends GenericDaoImpl<Review, Long> implements ReviewDAO {

	@Override
	public Review findProductByNick(String nick) {
		return getObjectByCriteria(createDetachedCriteria().add(Restrictions.eq(Review.NICK, nick)));
	}

	@Override
	public Review findProductByReview_date(Date review_date) {
		return getObjectByCriteria(createDetachedCriteria().add(Restrictions.eq(Review.REVIEW_DATE, review_date)));
	}
}
